'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 离线奖励
 * @author sundbcn@gmail.com (sun debing)
 */

var _ = require('lodash');
var dataApi = require('../libs/dataApi');

/**
 * 获取离线配置
 * @param  {[type]} reward_id [description]
 * @return {[type]}           [description]
 */
exports.getConf = function (nexus_lv, day_id) {
    var max_day = 0;
    var min_day = 0;
    var list = [];

    dataApi.offline_day_ratio.each(function (item) {
        if (item.id > max_day) {
            max_day = item.id;
        }
    });

    if (day_id > max_day) {
        day_id = max_day;
    }
    var day_ratio = dataApi.offline_day_ratio.findById(day_id) || 0;
    var reward_list = dataApi.offline_reward.findById(nexus_lv);
    if (!reward_list) {
        console.error('not nexus lv reward ---- :', nexus_lv);
        reward_list = [];
    }
    return {
        day_ratio: day_ratio.reward_type,
        reward_list: reward_list,
        day: day_id
    };

};
